// import { defineConfig,ConfigEnv,UserConfigExport,loadEnv } from 'vite'
import { loadEnv } from 'vite'
import { type ConfigEnv} from 'vite'
import vue from '@vitejs/plugin-vue'
// import {createSvgIconsPlugin} from 'vite-plugin-svg-icons'
import {viteMockServe} from "vite-plugin-mock"
import path from "path"
//@ts-ignore

export default({command,mode}:ConfigEnv):UserConfigExport=>{
  let env=loadEnv(mode,process.cwd())
  return {
    plugins:[
      vue(),
      // createSvgIconsPlugin({
      //   iconDirs:[path.resolve(process.cwd(),'src/assets/icons')],
      //   symbolId:'icon-[dir]-[name]',
      // }),
      viteMockServe({
        localEnabled:command==='serve'
      }),
    ],
    resolve:{
      alias:{
        '@views': path.resolve('./src/views'),
        "@":path.resolve("./src")
      }
    },

    server:{
      proxy:{
        [env.VITE_APP_BASE_API]:{
          target:env.VITE_APP_SERVICE_URL,
          changeOrigin:true,
          rewrite:(path:string)=>path.replace(/^\/dev-api/,'')
        }
      }
    }
  }
}

// https://vite.dev/config/
// export default defineConfig({
//   plugins: [vue()],
//   resolve:{
//     alias:{
//       "@":path.resolve("./src")
//     }
//   }
// })
